Generalized trigonometry